﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using CE.Database;
using CE.Global;

public partial class car_insurance_StepCarYear : MyLanguageAndSessionBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["carmake"] != null && Request.QueryString["carmake"].ToString() != "")
            {
                BindRptCarYear(Request.QueryString["carmake"].ToString(), Request.QueryString["carmodel"].ToString().Replace("%20"," "));
            }
        }
    }
    private void BindRptCarYear(string makeCode,string model)
    {
        MyDatabase _db = new MyDatabase();
        DataTable _dt = new DataTable("tblCarModel");
        SortedList _spList = new SortedList();
        _spList.Add("@CarMake", makeCode);
        _spList.Add("@CarModel", model);
        _dt = _db.GetDataTableBySP("sprocGetCarYearByMakeAndModel", _spList);

        if (_dt != null && _dt.Rows.Count > 0)
        {
            rptCarYear.DataSource = _dt;
            rptCarYear.DataBind();
        }

        _dt = null;
        _db = null;
    }
    protected void rptCarYear_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
        }
        if (e.CommandName.ToLower().Equals("moreinfo"))
        {
        }
    }

    protected void rptCarYear_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            HyperLink hplCarYear = (HyperLink)e.Item.FindControl("hplCarYear");
            Label lblCarYear = (Label)e.Item.FindControl("lblCarYear");
            hplCarYear.NavigateUrl = "~/car-insurance/Class1Person.aspx" + "?caryear=" + lblCarYear.Text;
        }
    }
}
